using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;


namespace  TowerDefence_QF
{
    public class UdpateHpCmd : AbstractCommand
    {
        protected override void OnExecute()
        {
            var gameModel = this.GetModel<GameModel>();
            gameModel.HP--;
            if (gameModel.HP <= 0)
            {
                gameModel.HP = 0;
                gameModel.GameState = GameState.GameOver;
            }
            this.SendEvent(new UdpateHPEvent( gameModel.HP));
            
            if(gameModel.GameState==GameState.GameOver)
                StringEventSystem.Global.Send(NameData.END_LEVEL);
        }
    }
}

